package edu.cibertec.sicsolutions.vfs.dao.votacion.ibatis;
import edu.cibertec.sicsolutions.vfs.dao.votacion.CedulaDao;
import edu.cibertec.sicsolutions.vfs.domain.votacion.Cedula;
import edu.cibertec.sicsolutions.vfs.spring.SpringIbatisBase;
import edu.cibertec.sicsolutions.exception.DaoException;
import java.util.List;
import java.util.Map;

/**
 * Data Access Object Implementation of table CEDULA 
 * @author enrique.vargas
 *
 */
public class CedulaDaoImpl extends SpringIbatisBase implements CedulaDao {	

	public Cedula getCedulaByPk(Cedula cedula) throws DaoException{
		try{
			return (Cedula)queryForObject("getCedulaByPk", cedula);
		} catch(Exception e){
			log.error(e.getMessage(), e);
			throw new DaoException(e.getMessage(), e);
		}		
	}
	
	public void insertCedula(Cedula cedula) throws DaoException{
		try{
			insert("insertCedula", cedula);
		} catch(Exception e){
			log.error(e.getMessage(), e);
			throw new DaoException(e.getMessage(), e);
		}		
	}
	
	public void updateCedula(Cedula cedula) throws DaoException{		
		try{
			update("updateCedula", cedula);
		} catch(Exception e){
			log.error(e.getMessage(), e);
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	public void updateCedulaByMap(Map map) throws DaoException{		
		try{
			update("updateCedulaByMap", map);
		} catch(Exception e){
			log.error(e.getMessage(), e);
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	public void deleteCedulaByPk(Cedula cedula) throws DaoException{		
		try{
			delete("deleteCedulaByPk", cedula);
		} catch(Exception e){
			log.error(e.getMessage(), e);
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	public Cedula[] findCedulaByClass(Cedula cedula) throws DaoException{
		try{
			List list = queryForList("findCedulaByClass", cedula);
			return (Cedula[])list.toArray(new Cedula[list.size()]);
		} catch(Exception e){
			log.error(e.getMessage(), e);
			throw new DaoException(e.getMessage(), e);
		}
	}
	
	public Cedula[] findAniosCedula()throws DaoException{
		try{
			List list = queryForList("findAniosCedula");
			return (Cedula[])list.toArray(new Cedula[list.size()]);
		} catch(Exception e){
			log.error(e.getMessage(), e);
			throw new DaoException(e.getMessage(), e);
		}
		
	}
}